<?php
/**
 * Created by PhpStorm.
 * User: Dave
 * Date: 2018/5/10
 * Time: 10:57
 */

namespace Biz\service;

use Biz\tools\BizUrl;
use Biz\tools\Link as tLink;
use Biz\tools\SmallProgram as tSmallProgram;
use Doraemon\tools\Hhzurl;
use Doraemon\tools\ImgUrl;
/**
 * @deprecated
 */
class Share
{
    public static function getSpecialShare($specialInfo)
    {
        $title = $specialInfo['share_title'];

        $desc = $specialInfo['share_desc'];

        // 分享h5地址
        $link = BizUrl::h5SpecialInfo($specialInfo['id']);
        $sharePage = '&in_app=2&inthematic=2&';
        $shareInfo = array();
        // wechat
        $shareInfo['wechat']['title'] = (string)$title;
        $shareInfo['wechat']['desc'] = (string)$desc;
        $shareInfo['wechat']['cover_img'] = (string)$specialInfo['share_img'];
        $shareInfo['wechat']['url'] = (string)$link . $sharePage;
        // 微信小程序
        $shareInfo['wechat']['mini_program']['path'] = tSmallProgram::getSpecialLink($specialInfo['id']);
        $shareInfo['wechat']['mini_program']['userName'] = tSmallProgram::smallProgramId();
        $shareInfo['wechat']['mini_program']['in_app_link'] = tLink::format(tLink::LINK_H5, $link, true);
        // wechat_moments
        $shareInfo['wechat_moments']['title'] = (string)$title;
        $shareInfo['wechat_moments']['cover_img'] = (string)$specialInfo['share_img'];
        $shareInfo['wechat_moments']['url'] = (string)$link . $sharePage;
        // weibo
        $shareInfo['weibo']['title'] = (string)$title . ' @好好住APP 点击看详情→链接 ' . $link . $sharePage;
        $shareInfo['weibo']['cover_img'] = (string)$specialInfo['share_img'];
        $shareInfo['weibo']['url'] = (string)$link . $sharePage;
        // qq
        $shareInfo['qq']['title'] = (string)$title;
        $shareInfo['qq']['desc'] = (string)$desc;
        $shareInfo['qq']['cover_img'] = (string)$specialInfo['share_img'];
        $shareInfo['qq']['url'] = (string)$link . $sharePage;
        return $shareInfo;
    }

    public static function getGoodsShare($goodsInfo)
    {

        $title = $goodsInfo['title'];
        $brandName = $goodsInfo['brand_info']['name'];
        $desc = $goodsInfo['title'];
        $img = ImgUrl::getUrl(ImgUrl::APPTYPE_BIZ, $goodsInfo['spec_img'],
            ImgUrl::IMAGE_SIZE_SQ_THUMB);

        $link = BizUrl::h5GoodsInfo($goodsInfo['goods_id']);

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)($brandName . " " . $title);
        $share_info['wechat']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['wechat']['cover_img'] = (string)$img;
        $share_info['wechat']['url'] = (string)$link;
        // 微信小程序
//        $share_info['wechat']['mini_program']['path'] = tSmallProgram::getGoodsDetailLink($goodsInfo['goods_id']);
//        $share_info['wechat']['mini_program']['userName'] = tSmallProgram::smallProgramId();
//        $share_info['wechat']['mini_program']['in_app_link'] = tLink::format(tLink::LINK_MALL_GOODS_ID, $goodsInfo['goods_id']);
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)("好好住APP| " . $brandName . " " . $title);
        $share_info['wechat_moments']['cover_img'] = (string)$img;
        $share_info['wechat_moments']['url'] = (string)$link;
        // weibo
        $share_info['weibo']['title'] = "在好好住APP看上了这个，快帮我看看：" . $brandName . " " . $title . " " . $link;
        $share_info['weibo']['cover_img'] = (string)$img;
        $share_info['weibo']['url'] = (string)$link;
        // qq
        $share_info['qq']['title'] = (string)($brandName . " " . $title);
        $share_info['qq']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['qq']['cover_img'] = (string)$img;
        $share_info['qq']['url'] = (string)$link;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;

    }

    public static function getGoodsPintuanShare($goodsInfo, $team)
    {

        $title = $goodsInfo['title'];
        $brandName = $goodsInfo['brand_info']['name'];
        $desc = $goodsInfo['title'];
        $img = ImgUrl::getUrl(ImgUrl::APPTYPE_BIZ, $goodsInfo['spec_img'],
            ImgUrl::IMAGE_SIZE_SQ_THUMB);

        $link = BizUrl::h5GoodsPintuan($team['team_join_id']);

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)('发现一件好商品,拼团仅需¥' . $team['group_buy_price']);
        $share_info['wechat']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['wechat']['cover_img'] = (string)$img;
        $share_info['wechat']['url'] = (string)$link;
        // 微信小程序
        $share_info['wechat']['mini_program']['path'] = tSmallProgram::getGoodsPintuanLink($team['team_join_id']);
        $share_info['wechat']['mini_program']['userName'] = tSmallProgram::smallProgramId();
        $share_info['wechat']['mini_program']['in_app_link'] = 'hhzb://' . base64_encode(BizUrl::h5GoodsPintuan($team['team_join_id'], false));
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)("好好住APP| " . $brandName . " " . $title);
        $share_info['wechat_moments']['cover_img'] = (string)$img;
        $share_info['wechat_moments']['url'] = (string)$link;
        // weibo
        $share_info['weibo']['title'] = "在好好住APP看上了这个，快帮我看看：" . $brandName . " " . $title . " " . $link;
        $share_info['weibo']['cover_img'] = (string)$img;
        $share_info['weibo']['url'] = (string)$link;
        // qq
        $share_info['qq']['title'] = (string)($brandName . " " . $title);
        $share_info['qq']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['qq']['cover_img'] = (string)$img;
        $share_info['qq']['url'] = (string)$link;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;

    }

    public static function getActivityShare($activityInfo)
    {
        $title = $activityInfo['share_title'];

        $desc = $activityInfo['share_desc'];

        // 分享h5地址
        $link = BizUrl::h5ShopActivity($activityInfo['id'], 2);
        $shareInfo = array();
        // wechat
        $shareInfo['wechat']['title'] = (string)$title;
        $shareInfo['wechat']['desc'] = (string)$desc;
        $shareInfo['wechat']['cover_img'] = (string)$activityInfo['share_img'];
        $shareInfo['wechat']['url'] = (string)$link;
        // wechat_moments
        $shareInfo['wechat_moments']['title'] = (string)$title;
        $shareInfo['wechat_moments']['cover_img'] = (string)$activityInfo['share_img'];
        $shareInfo['wechat_moments']['url'] = (string)$link;
        // weibo
        $shareInfo['weibo']['title'] = (string)$title . ' @好好住APP 点击看详情→链接 ' . $link;
        $shareInfo['weibo']['cover_img'] = (string)$activityInfo['share_img'];
        $shareInfo['weibo']['url'] = (string)$link;
        // qq
        $shareInfo['qq']['title'] = (string)$title;
        $shareInfo['qq']['desc'] = (string)$desc;
        $shareInfo['qq']['cover_img'] = (string)$activityInfo['share_img'];
        $shareInfo['qq']['url'] = (string)$link;
        return $shareInfo;
    }

    public static function getMealShare($meal)
    {
        $title = $meal['meal_title'];

        // 分享h5地址
        $link = BizUrl::h5MealInfo($meal['meal_id']);
        $shareInfo = array();
        // wechat
        $shareInfo['wechat']['title'] = (string)'好好住丨建材一站购 ' . $title;
        $shareInfo['wechat']['desc'] = (string)'这个套餐好像很不错啊！你点开看看？';
        $shareInfo['wechat']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['wechat']['url'] = (string)$link;
        // wechat_moments
        $shareInfo['wechat_moments']['title'] = (string)'好好住丨建材一站购 ' . $title;
        $shareInfo['wechat_moments']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['wechat_moments']['url'] = (string)$link;
        // weibo
        $shareInfo['weibo']['title'] = (string)'推荐好好住APP上这个「建材一站购」套餐，装修方便了好多： ' . $title . $link;
        $shareInfo['weibo']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['weibo']['url'] = (string)$link;
        // qq
        $shareInfo['qq']['title'] = (string)'好好住丨建材一站购 ' . $title;
        $shareInfo['qq']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['qq']['url'] = (string)$link;
        return $shareInfo;
    }

    public static function getDoubleEleven()
    {
        $link = BizUrl::h5Lottery();
        $title = '';
        $meal['cover_img'] = 'http://img.hhz1.cn/Op-imageShow/f855a205k05k00000phgjhh?iv=1';
        $shareInfo = array();
        // wechat
        $shareInfo['wechat']['title'] = (string)'我的天，差点抽中戴森卷发棒 ' . $title;
        $shareInfo['wechat']['desc'] = (string)'中奖率100%！好好住商城的抽奖转盘果然是良心转盘！';
        $shareInfo['wechat']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['wechat']['url'] = (string)$link;
        // wechat_moments
        $shareInfo['wechat_moments']['title'] = (string)'我的天，差点抽中戴森卷发棒 ' . $title;
        $shareInfo['wechat_moments']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['wechat_moments']['url'] = (string)$link;
        // weibo
        $shareInfo['weibo']['title'] = (string)'我的天，差点抽中戴森卷发棒 ' . $title . $link;
        $shareInfo['weibo']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['weibo']['url'] = (string)$link;
        // qq
        $shareInfo['qq']['title'] = (string)'我的天，差点抽中戴森卷发棒 ' . $title;
        $shareInfo['qq']['cover_img'] = (string)$meal['cover_img'];
        $shareInfo['qq']['desc'] = (string)'中奖率100%！好好住商城的抽奖转盘果然是良心转盘！';
        $shareInfo['qq']['url'] = (string)$link;
        return $shareInfo;
    }

    public static function getGroupBuyShare($groupId)
    {
        // 微信小程序
        $shareInfo['wechat']['mini_program']['path'] = tSmallProgram::getGroupBuyDetailLink($groupId);
        $shareInfo['wechat']['mini_program']['userName'] = tSmallProgram::smallProgramId();
        return $shareInfo;
//        $share_info['wechat']['mini_program']['in_app_link'] = tLink::format(tLink::LINK_MALL_GOODS_ID, $groupId);
    }

    public static function getWikiShare($wikiInfo)
    {
        $title = $wikiInfo['title'];
        $brandName = isset($wikiInfo['brand_info']['name']) ? $wikiInfo['brand_info']['name'] : '';
        $desc = $wikiInfo['title'];
        $img = $wikiInfo['cover_img'];

        $link = Hhzurl::H5WikiDetails($wikiInfo['id']);

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)($brandName . " " . $title);
        $share_info['wechat']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['wechat']['cover_img'] = (string)$img;
        $share_info['wechat']['url'] = (string)$link;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)("好好住APP| " . $brandName . " " . $title);
        $share_info['wechat_moments']['cover_img'] = (string)$img;
        $share_info['wechat_moments']['url'] = (string)$link;
        // weibo
        $share_info['weibo']['title'] = "在好好住APP看上了这个，快帮我看看：" . $brandName . " " . $title . " " . $link;
        $share_info['weibo']['cover_img'] = (string)$img;
        $share_info['weibo']['url'] = (string)$link;
        // qq
        $share_info['qq']['title'] = (string)($brandName . " " . $title);
        $share_info['qq']['desc'] = "好喜欢这个，快帮我看看~";
        $share_info['qq']['cover_img'] = (string)$img;
        $share_info['qq']['url'] = (string)$link;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;

    }

    public static function getCourseShare($courseInfo)
    {

        $title = $courseInfo['share_title'] ? $courseInfo['share_title'] : $courseInfo['title'];
        $desc = $courseInfo['share_desc'] ? $courseInfo['share_desc'] : $courseInfo['desc'];
        $shareImg = $courseInfo['share_img'] ? $courseInfo['share_img'] : $courseInfo['teacher_img'];

        $link = Hhzurl::h5ShareCourse($courseInfo['course_id']);

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)($title);
        $share_info['wechat']['desc'] = (string)$desc;
        $share_info['wechat']['cover_img'] = (string)$shareImg;
        $share_info['wechat']['url'] = (string)$link;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)($title);
        $share_info['wechat_moments']['cover_img'] = (string)$shareImg;
        $share_info['wechat_moments']['url'] = (string)$link;
        // weibo
        $share_info['weibo']['title'] = (string)($title);
        $share_info['weibo']['cover_img'] = (string)$shareImg;
        $share_info['weibo']['url'] = (string)$link;
        // qq
        $share_info['qq']['title'] = (string)($title);
        $share_info['qq']['desc'] = (string)$desc;
        $share_info['qq']['cover_img'] = (string)$shareImg;
        $share_info['qq']['url'] = (string)$link;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;

    }

    //专题分享
    public static function getDecorationShare($data, $coverImg = '')
    {
        $coverImg = $coverImg ? $coverImg : 'http://img.hhz1.cn/Op-imageShow/8090520hs0hs00000p8i62j?iv=1';
        $title = '装修必看：' . $data['name'];
        $link = Hhzurl::h5Decoration($data['id']);
        $desc = '汇聚住友实用经验，少走弯路不花冤枉钱';

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)$title;
        $share_info['wechat']['desc'] = $desc;
        $share_info['wechat']['url'] = (string)$link;
        $share_info['wechat']['cover_img'] = (string)$coverImg;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)$title;
        $share_info['wechat_moments']['url'] = (string)$link;
        $share_info['wechat_moments']['cover_img'] = (string)$coverImg;
        // weibo
        $share_info['weibo']['title'] = (string)$title . " " . $link;
        $share_info['weibo']['url'] = (string)$link;
        $share_info['weibo']['cover_img'] = (string)$coverImg;
        // qq
        $share_info['qq']['title'] = (string)$title;
        $share_info['qq']['desc'] = $desc;
        $share_info['qq']['url'] = (string)$link;
        $share_info['qq']['cover_img'] = (string)$coverImg;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;

    }

    /**
     * 榜单聚合页分享
     * @return array
     */
    public static function getRankingShare()
    {
        $coverImg = 'http://img.hhz1.cn/Op-imageShow/38036305k05k02A00r1o4cp?iv=1';
        $title = '好好住｜好物榜单，百万住友亲选';
        $link = Hhzurl::h5ShareRanking();
        $desc = '选好物，看榜单。少走冤枉路，不花冤枉钱！';

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)$title;
        $share_info['wechat']['desc'] = $desc;
        $share_info['wechat']['url'] = (string)$link;
        $share_info['wechat']['cover_img'] = (string)$coverImg;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)$title;
        $share_info['wechat_moments']['url'] = (string)$link;
        $share_info['wechat_moments']['cover_img'] = (string)$coverImg;
        // weibo
        $share_info['weibo']['title'] = (string)$title . " " . $link;
        $share_info['weibo']['url'] = (string)$link;
        $share_info['weibo']['cover_img'] = (string)$coverImg;
        // qq
        $share_info['qq']['title'] = (string)$title;
        $share_info['qq']['desc'] = $desc;
        $share_info['qq']['url'] = (string)$link;
        $share_info['qq']['cover_img'] = (string)$coverImg;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;
    }

    /**
     * 榜单-分类榜单页分享
     * @param $rankingId
     * @param $rankingName
     * @return array
     */
    public static function getRankingHotShare($rankingId, $rankingName)
    {
        $coverImg = 'http://img.hhz1.cn/Op-imageShow/38036305k05k02A00r1o4cp?iv=1';
        $title = '好好住' . $rankingName . '榜';
        $link = Hhzurl::h5ShareRankingHot($rankingId);
        $desc = '百万住友购物心得大汇总，快来看看住友都Pick的' . $rankingName . '吧！';

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)$title;
        $share_info['wechat']['desc'] = $desc;
        $share_info['wechat']['url'] = (string)$link;
        $share_info['wechat']['cover_img'] = (string)$coverImg;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)$title;
        $share_info['wechat_moments']['url'] = (string)$link;
        $share_info['wechat_moments']['cover_img'] = (string)$coverImg;
        // weibo
        $share_info['weibo']['title'] = (string)$title . " " . $link;
        $share_info['weibo']['url'] = (string)$link;
        $share_info['weibo']['cover_img'] = (string)$coverImg;
        // qq
        $share_info['qq']['title'] = (string)$title;
        $share_info['qq']['desc'] = $desc;
        $share_info['qq']['url'] = (string)$link;
        $share_info['qq']['cover_img'] = (string)$coverImg;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;
    }

    /**
     * 榜单-品牌荣耀页分享
     * @param $rankingId
     * @return array
     */
    public static function getBrandGloryShare($brandId, $brandInfo, $fans)
    {
        $coverImg = $brandInfo ? $brandInfo['logo'] : '';
        $title = $brandInfo ? $brandInfo['name'] : '';
        $title .= '上榜啦！';
        $link = Hhzurl::h5ShareBrandGlory($brandId);
        if ($fans > 10000) {
            $fans = sprintf("%.1f", $fans / 10000) . 'W';
        }
        $desc = $fans ? ($fans . '住友都喜欢Ta，快来看看吧！') : '这可是千万住友为你挑出来的优质品牌哦';

        $share_info = array();
        // wechat
        $share_info['wechat']['title'] = (string)$title;
        $share_info['wechat']['desc'] = $desc;
        $share_info['wechat']['url'] = (string)$link;
        $share_info['wechat']['cover_img'] = (string)$coverImg;
        // wechat_moments
        $share_info['wechat_moments']['title'] = (string)$title;
        $share_info['wechat_moments']['url'] = (string)$link;
        $share_info['wechat_moments']['cover_img'] = (string)$coverImg;
        // weibo
        $share_info['weibo']['title'] = (string)$title . " " . $link;
        $share_info['weibo']['url'] = (string)$link;
        $share_info['weibo']['cover_img'] = (string)$coverImg;
        // qq
        $share_info['qq']['title'] = (string)$title;
        $share_info['qq']['desc'] = $desc;
        $share_info['qq']['url'] = (string)$link;
        $share_info['qq']['cover_img'] = (string)$coverImg;

        $share_info['share_link']['url'] = (string)$link;

        return $share_info;
    }


    /**
     * 门店主页分享
     * @param $store_info
     * @return array
     */
    public static function getStoreGloryShare($store_info): array
    {
        $link = BizUrl::storeHome($store_info['uid']);
        $share_info['wechat']['title'] = (string)$store_info['store_name'];
        $share_info['wechat']['desc'] = (string)$store_info['desc'];
        $share_info['wechat']['cover_img'] = $store_info['cover_pic_url'];
        $share_info['wechat']['url'] = $link;

        $share_info['only_show_wechat'] = 1;
        // 微信小程序
        $share_info['wechat']['mini_program']['path'] = $link;
        $share_info['wechat']['mini_program']['userName'] = 'gh_cce5c3e16ee4';
        return $share_info;
    }


}